 #define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int c = a % b;
	if (c != 0)
	{
		a = b;
		b = c;
		int c = a % b;



	}
	printf("%d", b);









}